/**
  ******************************************************************************
  * @file    main.c
  * @author  armwind.chen@foxmail.com
  * @version V1.0
  * @date    2019.10.1
  * @brief   主程序启动后，led会间隔1s闪烁。
  * @宝贝链接：https://item.taobao.com/item.htm?spm=a2oq0.12575281.0.0.50111debxjgygH&ft=t&id=626242045207
  ******************************************************************************
  */
#include "led.h"
#include "usart.h"
#include "log.h"
#include "relay.h"

//如果日志等级大于LOG_DEBUG，则会打印该日志，反之不会。
#define LOG_LOCAL_LEVEL LOG_DEBUG
#define TAG  "MAIN:"

__STATIC_FORCEINLINE uint32_t __get_PRIMASK1(void)
{
  uint32_t result;

  __ASM volatile ("MRS %0, primask" : "=r" (result) :: "memory");
  return(result);
}

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Add your application code here
   *
   */
    //delay_init();
    usart_config(1,9600);   //串口1波特率9600
    led_init();             //初始化LED
    relay_init();           //初始化继电器
    TIM_Init();           //  初始化定时器

  /* Infinite loop */
    while (1) {
            //led_set(LED_ON);
            delay_ms(500);
            //led_set(LED_OFF);
            delay_ms(500);
            //LOGI("pending:0x%x",__NVIC_GetPendingIRQ(TIM3_IRQn));
            //LOGI("mask:%d",__get_PRIMASK1());
            for(int i =0; i< 8; i++)
            LOGI("pending[reg:%d]:0x%x",i, NVIC->ISPR[i]);
            for(int i =0; i< 8; i++)
            LOGI("enable_isr[%d]:0x%x",i,NVIC->ISER[i]);
            //if (0x8010000 == NVIC->ISER[0])
            //    led_set(LED_ON);
    }
}
/************************ (C) COPYRIGHT weiduwulian*****END OF FILE****/
